//
//  AAAVC.m
//  PlayerVH
//
//  Created by 彭冲 on 4/6/18.
//  Copyright © 2018年 彭冲. All rights reserved.
//

#import "AAAVC.h"

@interface AAAVC ()

@property (nonatomic, assign) BOOL isHidden;
@property (nonatomic, assign) BOOL isWhite;

@end

@implementation AAAVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view
    
    self.view.backgroundColor = [UIColor lightGrayColor];
    
    UIButton *bb = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 150, 50)];
    [bb setTitle:@"白色/黑色" forState:0];
    bb.backgroundColor = [UIColor blackColor];
    [self.view addSubview:bb];
    [bb addTarget:self action:@selector(bbClick) forControlEvents:64];
    
    UIButton *aa = [[UIButton alloc] initWithFrame:CGRectMake(100, 300, 100, 50)];
    [aa setTitle:@"隐藏/显示" forState:0];
    aa.backgroundColor = [UIColor blackColor];
    [self.view addSubview:aa];
    [aa addTarget:self action:@selector(aaClick) forControlEvents:64];
}

- (void)bbClick {
    self.isWhite = !self.isWhite;
    [UIView animateWithDuration:0.3 animations:^{
        [self setNeedsStatusBarAppearanceUpdate];
    }];
}

- (void)aaClick {
    self.isHidden = !self.isHidden;
    [UIView animateWithDuration:0.3 animations:^{
        [self setNeedsStatusBarAppearanceUpdate];
    }];
}

- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
    return UIStatusBarAnimationSlide;
}

- (BOOL)prefersStatusBarHidden {
    return self.isHidden;
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    if (self.isWhite == YES) {
        return UIStatusBarStyleLightContent; //显示白色
    }else{
        return UIStatusBarStyleDefault;
    }
}

@end
